<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="inputs">
        <input type="text"><br>
        <input type="text"><br>
        <input type="text"><br>
        <input type="text"><br>
        <input type="text"><br>
        <input type="text"><br>
        <input type="text"><br>
        <input type="text">
    </div>
    <script>
        var inputs = document.getElementById("inputs").children
        for (var i = 0 ; i < inputs.length ; i++) {
            inputs[i].onfocus = function () {
                for (var j = 0 ; j <inputs.length ; inputs++) {
                    inputs[j].style.backgroundColor = "white";
                }
                this.style.backgroundColor = "gray";
            }
            inputs[i].onblur = function () {
                this.style.backgroundColor = "white"
            }
        }
    </script>
</body>
</html>